﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace SharePointCustomizer
{
    public partial class CSSViewer : Form
    {
        public string strCssAll;
        Find findForm;
        public string strHighlight;
        /// <summary>
        /// 
        /// </summary>
        public CSSViewer()
        {
            InitializeComponent();
        }
        /// <summary>
        /// CSSViewer Load
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void CSSViewer_Load(object sender, EventArgs e)
        {
            txtViewer.Text = strCssAll;
            txtViewer.Find(strHighlight, RichTextBoxFinds.WholeWord);
        }
        /// <summary>
        /// copyToolStripMenuItem Click
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void copyToolStripMenuItem_Click(object sender, EventArgs e)
        {
            txtViewer.Copy();
        }
        /// <summary>
        /// exitToolStripMenuItem Click
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void exitToolStripMenuItem_Click(object sender, EventArgs e)
        {
            this.Owner.Activate();
            this.Dispose();
        }
        /// <summary>
        /// findToolStripMenuItem Click
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void findToolStripMenuItem_Click(object sender, EventArgs e)
        {
            findForm = new Find(txtViewer);
            findForm.Show();
        }
        /// <summary>
        /// copyToolStripMenuItem1 Click
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void copyToolStripMenuItem1_Click(object sender, EventArgs e)
        {
            txtViewer.Copy();
        }
        /// <summary>
        /// fontToolStripMenuItem Click
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void fontToolStripMenuItem_Click(object sender, EventArgs e)
        {
            fontDialog.Font = txtViewer.Font;
            fontDialog.ShowDialog(this);
            txtViewer.Font = fontDialog.Font;
        }
        /// <summary>
        /// wordWrapToolStripMenuItem Click
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void wordWrapToolStripMenuItem_Click(object sender, EventArgs e)
        {
            if(wordWrapToolStripMenuItem.Checked)
            {
                txtViewer.WordWrap = true;
            }else
            {
                txtViewer.WordWrap = false;
            }
            
        }
        /// <summary>
        /// txtViewer PreviewKeyDown
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void txtViewer_PreviewKeyDown(object sender, PreviewKeyDownEventArgs e)
        {
            if (e.KeyCode == Keys.Enter)
            {
                if (findForm != null)
                {
                    if (findForm.Visible)
                    {
                        findForm.btnFindNext.PerformClick();
                    }
                }
            }
        }
    }
}
